package com.zhou.system.management.security.listener;

import com.zhou.common.operator.log.core.service.OperateLogStorageService;
import com.zhou.system.management.security.model.MyUserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.event.LogoutSuccessEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 区分不了是自己退出，还是超出并发数被退出的
 * @author xianfeng
 * @date 2023/5/13 17:31
 */
@Slf4j
@Component
public class LogoutListener {

    @Resource
    private OperateLogStorageService logService;

    @EventListener
    public void handleMyEventMap(LogoutSuccessEvent logoutSuccessEvent) {
        MyUserDetails currentUser = (MyUserDetails) logoutSuccessEvent.getAuthentication().getPrincipal();
        log.info("{}登出成功:手动退出", currentUser.getUsername());
    }
}
